home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Adobe Air 1.5 / AdobeAIRInstaller.exe / setup.swf / scripts / mx / states / RemoveChild.as < prev    next >
Encoding:
Text File  |  2008-10-29  |  1.4 KB  |  59 lines

  1. package mx.states
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.display.DisplayObjectContainer;
  5.    import mx.core.UIComponent;
  6.    import mx.core.mx_internal;
  7.    
  8.    use namespace mx_internal;
  9.    
  10.    public class RemoveChild implements IOverride
  11.    {
  12.       mx_internal static const VERSION:String = "3.0.0.0";
  13.       
  14.       private var removed:Boolean;
  15.       
  16.       private var oldIndex:int;
  17.       
  18.       private var oldParent:DisplayObjectContainer;
  19.       
  20.       public var target:DisplayObject;
  21.       
  22.       public function RemoveChild(param1:DisplayObject = null)
  23.       {
  24.          super();
  25.          this.target = param1;
  26.       }
  27.       
  28.       public function remove(param1:UIComponent) : void
  29.       {
  30.          if(removed)
  31.          {
  32.             oldParent.addChildAt(target,oldIndex);
  33.             if(target is UIComponent)
  34.             {
  35.                UIComponent(target).mx_internal::updateCallbacks();
  36.             }
  37.             removed = false;
  38.          }
  39.       }
  40.       
  41.       public function apply(param1:UIComponent) : void
  42.       {
  43.          removed = false;
  44.          if(target.parent)
  45.          {
  46.             oldParent = target.parent;
  47.             oldIndex = oldParent.getChildIndex(target);
  48.             oldParent.removeChild(target);
  49.             removed = true;
  50.          }
  51.       }
  52.       
  53.       public function initialize() : void
  54.       {
  55.       }
  56.    }
  57. }
  58.  
  59.